home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / obsolete / only_8bit.pro < prev    next >
Text File  |  1997-07-08  |  3KB  |  88 lines

  1. ; $Id: only_8bit.pro,v 1.2 1997/01/15 04:02:19 ali Exp $
  2. ;
  3. ; Copyright (c) 1987-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. pro only_8bit,mask = mask, colors = colors
  7. ;Set up IDL to work on a Sun with 8 bit color only.
  8. ;+
  9. ; NAME:
  10. ;    ONLY_8BIT
  11. ;
  12. ; PURPOSE:
  13. ;    Set up the Sun workstation colors (SunView) to work with IDL.
  14. ;    This procedure must be called before any windows are created.
  15. ;    It creates a window the number of colors specified by the COLORS
  16. ;    keyword (the default is 249).  The remaining colors are reserved for 
  17. ;    the other SunView windows.
  18. ;
  19. ;    Why a default of 249 colors?  This default leaves 7 colors for 
  20. ;    other windows which is adequate for most applications.  If this is not
  21. ;    enough, use the command:
  22. ;
  23. ;        ONLY_8BIT, COLORS=241, /MASK
  24. ;
  25. ;    leaving 15 colors for the other windows.
  26. ;
  27. ; CATEGORY:
  28. ;    General display.
  29. ;
  30. ; CALLING SEQUENCE:
  31. ;    ONLY_8BIT [, MASK = Mask] [, COLORS = Colors]
  32. ;
  33. ; INPUTS:
  34. ;    None.
  35. ;
  36. ; Keyword Input parameters:
  37. ;    MASK:    Set this keyword to set the write mask to disable writing 
  38. ;        the low-order bits.  If this keyword is set, images and color 
  39. ;        indices scaled in the normal range of 0 to 255 will appear 
  40. ;        properly, but without the full number of colors.
  41. ;
  42. ;        For example, if you specify 249 colors, leaving 8 for other 
  43. ;        windows, the write mask will be set to 'f8'x, disabling the 
  44. ;        writing of the bottom 3 bits.  Only 32 distinct colors will be 
  45. ;        written, but data scaled from 0 to 255 are written into
  46. ;        color indices 0 to 248.  If you can always scale your
  47. ;        images and color indices into the range 0 to 247, you
  48. ;        need not set the mask.
  49. ;
  50. ;      COLORS:    The number of color indices for IDL to use.  The default
  51. ;        is 249.
  52. ; OUTPUTS:
  53. ;    None.
  54. ;
  55. ; COMMON BLOCKS:
  56. ;    None.
  57. ;
  58. ; SIDE EFFECTS:
  59. ;    A window with only 249 colors is created and the write mask is
  60. ;    set to 255, passing all bits.
  61. ;
  62. ; RESTRICTIONS:
  63. ;    As described above.
  64. ;
  65. ; PROCEDURE:
  66. ;    Straightforward.
  67. ;
  68. ; MODIFICATION HISTORY:
  69. ;    DMS, 11/1987.
  70. ;    DMS, 3/6/89,    Modified to work with the new color table scheme,
  71. ;            which preserves the color mapping of indices not used
  72. ;            by IDL.
  73. ;-
  74. on_error,2                      ;Return to caller if an error occurs
  75. if n_elements(colors) eq 0 then colors = 249
  76. old_device = !d.name
  77. set_plot,'SUN3'
  78. window,colors=colors
  79. if keyword_set(mask) ne 0 then begin    ;Set write mask?
  80.     i = 0        ;# of bits enabled
  81.     while (255 and ((mask = 256-2^i))) gt colors do i=i+1
  82.     message, 'Mask set to ' + string(mask)
  83.     device,set_write = mask
  84.     endif
  85. set_plot,old_device
  86. end
  87.  
  88.